#include <stdio.h>
#include <stdlib.h>
int comp(const void*a,const void*b);
int main()
{
    srandom(8);
    int counter =0;
    int arr[11];
    for(;counter<11;counter++)
    {

        arr[counter] = random()%1000;
            }
    arr[11] = 330;
    qsort(arr,counter+1,sizeof(int),comp);

    int *item;
   int key = 330;

   item = (int*) bsearch (&key, arr,counter+1 , sizeof (int), comp);
   if( item != NULL )
   {
      printf("Found item = %d\n", *item);
   }
   else
   {
      printf("Item = %d could not be found\n", *item);
   }

}

int comp(const void*a,const void*b)
{
return *(int*)a-*(int*)b;
}
